 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  <%@ taglib prefix="s" uri="/struts-tags" %>
<form action="<s:url action="ledger"/>" method="post" accept-charset="utf-8" id="filter_form">

<div id="report_date_range_simple">
		<input type="radio" checked="checked" value="simple" id="simple_radio" name="report_type">
		<select id="report_date_range_simple" name="report_date_range_simple">
<option value="2012-06-15/2012-06-15">Today</option>
<option value="2012-06-14/2012-06-14">Yesterday</option>
<option value="2012-06-09/2012-06-15">Last 7 Days</option>
<option value="2012-06-01/2012-06-30">This Month</option>
<option value="2012-05-01/2012-05-31">Last Month</option>
<option value="2012-01-01/2012-12-31">This Year</option>
<option value="2011-01-01/2011-12-31">Last Year</option>
<option value="1969-12-31/2012-06-15">All Time</option>
</select>	</div>
<div id="report_date_range_complex">
		<input type="radio" value="complex" id="complex_radio" name="report_type">
		<select id="start_month" name="start_month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option selected="selected" value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>		<select id="start_day" name="start_day">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option selected="selected" value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>		<select id="start_year" name="start_year">
<option selected="selected" value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
</select>		-
		<select id="end_month" name="end_month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option selected="selected" value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="end_day" name="end_day">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option selected="selected" value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select id="end_year" name="end_year">
<option selected="selected" value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
</select>	</div>
</form>
  <script type="text/javascript">
                $(document).ready(function()
                {
                    init_table_sorting();
                    enable_select_all();
                    enable_checkboxes();
                    enable_row_selection();
                 });

                function init_table_sorting()
                {
                	//Only init if there is more than one row
                	if($('.tablesorter tbody tr').length >1)
                	{
                		$("#sortable_table").tablesorter(
                		{
                			sortList: [[1,0]],
                			headers:
                			{
                				0: { sorter: false},
                				5: { sorter: false}
                			}

                		});
                	}
                }
                function post_person_form_submit(response)
                {
                	if(!response.success)
                	{
                		set_feedback(response.message,'error_message',true);
                	}
                	else
                	{
                		//This is an update, just update one row
                		if(jQuery.inArray(response.person_id,get_visible_checkbox_ids()) != -1)
                		{
                			update_row(response.person_id,'${pageContext.request.contextPath}/customers/get_row');
                			set_feedback(response.message,'success_message',false);

                		}
                		else //refresh entire table
                		{
                			do_search(true,function()
                			{
                				//highlight new row
                				highlight_row(response.person_id);
                				set_feedback(response.message,'success_message',false);
                			});
                		}
                	}
                }
                </script>

                <table id="title_bar">
                	<tbody><tr>
                		<td id="title_icon">
                			<img alt="title icon" src="${pageContext.request.contextPath}/images/menubar/customers.png">
                		</td>
                		<td id="title">
                			List of Payments
                			</td>
                		<td id="title_search">
                			<form id="search_form" accept-charset="utf-8" method="post" action="${pageContext.request.contextPath}/customers/search">
                			<input type="text" id="search" name="search" class="ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
                				<img id="spinner" alt="spinner" src="${pageContext.request.contextPath}/images/spinner_small.gif">
                			</form>
                		</td>
                	</tr>
                	<tr>
                    <td id="commands" colspan="2">
                                    					<a title="New Employee" class="thickbox none new" href="${pageContext.request.contextPath}/payments/new.ps">New Payment</a>
                                    	</td>

                	</tr>
                </tbody></table>
                <table id="contents">
                	<tbody><tr>
                				<td id="item_table">
                			<div id="table_holder">
                			<table id="sortable_table" class="tablesorter">
                			<tr><th class="leftmost"><input type="checkbox" id="select_all"></th>
                            <th class="header headerSortDown">ID#</th>
                			<th class="header headerSortDown">Customer</th>
                            <th class="header headerSortDown">Received By</th>
                			<th class="header">Amount</th>
                			<th class="header">Date</th>
                			<th class="header">Type</th>
                			<th class="rightmost">Action</th>
                			</tr>
                            <jsp:useBean id="dateValue" class="java.util.Date" />


                			<c:forEach var="item" items="${paymentEntities}">
                             <tr style="cursor: pointer;">
                              <td width="5%" class=""><input type="checkbox" value="${item.id}" id="person_1773"></td>
                              <td width="20%" class=""><a class="underline" href="${pageContext.request.contextPath}/reports/list.ps?customerId=${item.id}">${item.id}</a></td>
                               <td width="20%" class=""><a class="underline" href="${pageContext.request.contextPath}/reports/list.ps?customerId=${item.id}">${item.customer.name}<br/>(${item.customer.city})</a></td>
                                <td width="20%" class=""><a class="underline" href="${pageContext.request.contextPath}/reports/list.ps?customerId=${item.id}">${item.employee.userName}</a></td>
                               <td width="20%" class=""><a class="underline" href="${pageContext.request.contextPath}/reports/list.ps?customerId=${item.id}">INR ${item.amount}</a></td>
                                 <jsp:setProperty name="dateValue" property="time" value="${item.paymentDate}" />

                              <td width="20%" class=""><fmt:formatDate pattern="dd/MM/yyyy hh:mm aaa"  value="${dateValue}" /></td>
                              <td width="20%" class="">${item.type.name}</td>
                             <td width="5%" class="rightmost"><a title="Update Payment" class="thickbox" href="${pageContext.request.contextPath}/payments/edit.ps?id=${item.id}">Edit</a></td>

                             </tr>
                            </c:forEach>

                              <tr><td colspan="2">Total Payment Amount</td><td>INR ${totalPaymentAmount}</td> </tr>



                			</table>
                			</div>
                			<div id="pagination">
                							</div>
                		</td>
                	</tr>
                </tbody></table>
                <div id="feedback_bar"></div>
